<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="box">
      <button data-action="save">保存</button>
      <button data-action="add">添加</button>
      <button data-action="del">删除</button>
    </div>
    <script>
      function save() {
        console.log("save");
      }

      function add() {
        console.log("add");
      }

      function del() {
        console.log("del");
      }

      document.getElementById("box").onclick = function (e) {
        if (e.target.innerHTML === "保存") {
          save();
        }
        if (e.target.innerHTML === "添加") {
          add();
        }
        if (e.target.innerHTML === "删除") {
          del();
        }
      };
    </script>
  </body>
</html>
